#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

DEB_DH_MAKESHLIBS_ARGS_ALL := -Xtritonus

export JAVA_HOME  = /usr/lib/jvm/java-gcj

JAVA       := $(JAVA_HOME)/bin/java
JAVAH      := $(CURDIR)/debian/javah
EXTENSIONS := alsa cdparanoia cooked_ioctl esd fluidsynth pvorbis vorbis

# We don't build the lame extension because lame is not part of Debian:
#EXTENSIONS := alsa cdparanoia cooked_ioctl esd fluidsynth lame pvorbis vorbis

post-patches:: debian/stamp-configure
debian/stamp-configure:
	autoconf
	chmod +x $(JAVAH)
	./configure --prefix=$(JAVA_HOME) JAVA=$(JAVA) JAVAH=$(JAVAH)
	touch $@

common-binary-indep:: debian/stamp-binary-indep
debian/stamp-binary-indep:
	ant -f build-dtd.xml
	CLASSPATH=/usr/share/java/jl.jar ant
	touch $@

common-binary-arch:: debian/stamp-binary-arch
debian/stamp-binary-arch:
	set -e && \
	  for EXT in $(EXTENSIONS); do \
	    $(MAKE) -C src/lib/$$EXT; \
	  done
	touch $@

install/libtritonus-java:: debian/stamp-binary-indep
	set -e && \
	  for JAR in dist/*.jar; do \
	    BASE=$$(basename $$JAR); \
	    dh_link /usr/share/java/$$BASE /usr/share/java/$${BASE%-*}.jar; \
	  done

clean::
	$(RM) debian/stamp-*

get-orig-source:
	sh debian/orig-tar.sh $(DEB_UPSTREAM_VERSION)
